package com.yidu.BusinessParameters.service.impl;

import com.yidu.BusinessParameters.entity.SecurityAccruedEntity;
import com.yidu.BusinessParameters.mapper.SecurityAccruedMapper;
import com.yidu.BusinessParameters.service.SecurityAccruedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SecurityAccruedServiceImpl implements SecurityAccruedService {

    @Autowired
    private SecurityAccruedMapper securityAccruedMapper;
    @Override
    public List<SecurityAccruedEntity> securityAccruedSelect() {
        return securityAccruedMapper.securityAccruedSelect();
    }

    @Override
    public List<SecurityAccruedEntity> securityAccruedSelects(int page, int limit, SecurityAccruedEntity securityAccruedEntity) {
        Map map = new HashMap<>();
        map.put("page",(page-1)*limit);
        map.put("limit",limit);
        map.put("moneyAllocate",strWriter(securityAccruedEntity));
        List<SecurityAccruedEntity> securityAccruedEntities = securityAccruedMapper.securityAccruedSelects(map);
        return securityAccruedEntities;
    }

    @Override
    public int securityAccruedinsert(SecurityAccruedEntity securityAccruedEntity) {
        return securityAccruedMapper.securityAccruedinsert(securityAccruedEntity);
    }

    @Override
    public int securityAccrueddelete(String securityAccruedId) {
        return securityAccruedMapper.securityAccrueddelete(securityAccruedId);
    }

    @Override
    public int securityAccruedupdate(SecurityAccruedEntity securityAccruedEntity) {
        return securityAccruedMapper.securityAccruedupdate(securityAccruedEntity);
    }

    @Override
    public int deleteSecurities(SecurityAccruedEntity securityAccruedEntity) {
        return securityAccruedMapper.deleteSecurities(securityAccruedEntity);
    }

    @Override
    public int two() {
        return securityAccruedMapper.two();
    }

    public String strWriter(SecurityAccruedEntity securityAccruedEntity){
        StringBuffer buffer = new StringBuffer("");
        if (securityAccruedEntity.getSecurityDate() != null && !securityAccruedEntity.getSecurityDate().equals("")){
            buffer.append("and securityDate = '"+securityAccruedEntity.getSecurityDate()+" '");
        }
        System.out.println("进入strWriter"+buffer.toString());
        return buffer.toString();
    }
}
